﻿using Himp.Platform.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;

namespace Himp.Platform
{
    public class MenuGrantRepository : EfCoreRepository<PlatformDbContext, Menu, Guid>, IMenuGrantRepository
    {
        public MenuGrantRepository(
            IDbContextProvider<PlatformDbContext> dbContextProvider)
            : base(dbContextProvider)
        {

        }

        /// <summary>
        /// 获取菜单
        /// </summary>
        /// <returns></returns>
        public async Task<List<Menu>> GetListAsync()
        {
            var menus = from menu in DbContext.Menus
                        from menuGrant in DbContext.MenuGrants
                        where menuGrant.MenuId == menu.Id
                        select menu;

            return menus.ToList();
        }
    }
}
